#DOWNGRADE ZELIG BY THE FOLLOWING COMMAND.
download http://r.iq.harvard.edu/src/contrib/Zelig_3.5.3.tar.gz
remove.packages("Zelig")
install.packages("ei", type="source", repos="http://r.iq.harvard.edu")
install.packages("Zelig_3.5.3.tar.gz", repos = NULL, type="source")
library(foreign)

library("Zelig")
mydata = read.dta("baskanlik.dta")
summary(mydata) 
 
  Sehir<- mydata
  z.out<-zelig(cbind(erdogan,ince,aksener,temel,demirtas,perincek,cbgecersiz)~akp+mhp+hudapar+vatan+hdp+chp+saadet+iyi+diger+mvgecersiz, model="ei.RxC", data=Sehir)
  s.out<-sim(z.out, num = 100)
  save.image("Baskanlik100Sims.RData")
  
  
  
  data<-data.frame(colMeans(s.out$qi$ev))
  data<-data.frame(colMeans(s.out$qi$ev))
  data<-cbind(RowNames = rownames(data), data)
  write.dta(data = data, paste("sehir",i,"dta",sep="."))

write.dta(data = mydata, "BASK.DTA")




